package com.sxds.wn.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import com.sxds.wn.IConstants;

/**
 * Description: <p>系统注销控制器</p>
 * Content Desc:<p>保存用户参数设置等，清除用户占有的资源<p>
 * Copy Right of Personal Tangtao 2007-2020
 * @author Andy
 * @version 1.0 Create Date:@2008-11-13
 */
public class ExitSystemController implements Controller,IConstants {
	
	private String homePage;

	/* (non-Javadoc)
	 * @see org.springframework.web.servlet.mvc.Controller#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	public ModelAndView handleRequest(HttpServletRequest request,HttpServletResponse response) throws Exception {
		HttpSession session = request.getSession(false);
		if( session!=null && session.getAttribute(USER_SESSION_KEY)!=null ){
			session.removeAttribute(USER_SESSION_KEY);
			session.invalidate();
		}
		response.sendRedirect(homePage);
		return null;
		//return new ModelAndView("index");
	}

	/**
	 * @return the homePage
	 */
	public String getHomePage() {
		return homePage;
	}

	/**
	 * @param homePage the homePage to set
	 */
	public void setHomePage(String homePage) {
		this.homePage = homePage;
	}

}
